package com.shycloud.mido.homework.pattern;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import com.shycloud.mido.common.api.constants.HomeWorkConstants;
import com.shycloud.mido.common.core.exception.BusinessException;
import com.shycloud.mido.common.core.util.R;
import com.shycloud.mido.homework.api.vo.HomeworkDashboardReqVO;
import com.shycloud.mido.homework.api.vo.HomeworkDashboardRespVO;
import com.shycloud.mido.homework.constant.Constant;

@Component(Constant.STU_MULTI_TARGET_RULE)
@Order(2)
public class StuMultiTargetRule extends BaseHomeworkDatas implements IHomeworkDashboardRule {

	@Override
	public R<Void> getViewDatas(LocalDate startDate, HomeworkDashboardReqVO vo, Map<LocalDate, HomeworkDashboardRespVO> resultMap) {
		//规则入参校验
		boolean studentFlag = vo.isStudentFlag();//true
		String mode = vo.getMode();//1
		String isParentMode = vo.getIsParentMode();//1
		String teacherId = vo.getTeacherId();//parentMode
		if (BooleanUtils.isTrue(studentFlag) && StringUtils.equals("1", mode) && StringUtils.equals("1", isParentMode) && StringUtils
				.equals(HomeWorkConstants.PARENT_MODE_TEACHER_ID, teacherId)) {
			HomeworkDashboardRespVO mapBean = new HomeworkDashboardRespVO();
			resultMap.put(startDate, mapBean);
			//String classroomId = vo.getClassroomId();
			String studentId = vo.getStudentId();
			List<String> teacherIds = new ArrayList<>();
			teacherIds.add(teacherId);

			super.getAllDatas(startDate, mapBean, studentId, teacherIds);
		} else {
			throw new BusinessException("参数异常");
		}
		return new R<Void>();
	}

}